home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-10 | 1017 b | 31 lines | [TEXT/MPS ] |
- #include "MacApp.h"
- #include <TAutoCentedView.h>
-
- //----------------------------------------------------------------------------------------
- // TAutoCenterView::SuperViewChangedFrame:
- //----------------------------------------------------------------------------------------
- #pragma segment MAViewNonRes
- pascal void TAutoCenterView::SuperViewChangedFrame(const VRect& oldFrame,
- const VRect& newFrame,
- Boolean invalidate)
- {
- VRect myExtent;
-
- inherited::SuperViewChangedFrame(oldFrame,newFrame,invalidate);
-
- GetFrame(myExtent); // in superview coordinates
- long myWidth = myExtent.GetLength(hSel); // get our width
- long hisWidth = newFrame.GetLength(hSel); // get the superview's new width
-
- if(myWidth < hisWidth) {
- long newLeft = (hisWidth - myWidth) / 2;
- myExtent.left = newLeft;
- myExtent.right = myExtent.left + myWidth;
- }
- else { // if the super view is too small, move all the way left
- myExtent.left = 0;
- myExtent.right = myWidth;
- }
- SetFrame(myExtent,invalidate);
- }
-